package com.uenpay.im.ui.old.activity.funds;

import android.util.Log;

import com.uenpay.im.configuration.APIConfiguration;
import com.uenpay.im.entities.HttpInvokeResult;
import com.uenpay.im.invokeitems.BaseHttpInvokeItem;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * @author SL
 * @created 2016-3-22 下午6:56:47
 * @copyRight http://www.qiyunxin.com
 * @function 设置群经费
 */
public class SetChatAmountInvokeItem extends BaseHttpInvokeItem {

	public class SetChatAmountInvokeItemResult extends HttpInvokeResult {
	}

	public SetChatAmountInvokeItemResult getOutPut() {
		return (SetChatAmountInvokeItemResult) GetResultObject();
	}

	/**
	 * 设置群经费
	 * 
	 * @param chatid
	 * @param amount
	 */
	public SetChatAmountInvokeItem(String chatid, String amount) {
		// http://api.qiyunxin.com/Chat/SpecialChat/setChatAmount?chatid=&amount=
		String url = APIConfiguration.getBaseUrl()
				+ "Chat/SpecialChat/setChatAmount?chatid=" + chatid
				+ "&amount=" + amount + "&"
				+ APIConfiguration.getCustIdAndToken();
		Log.e("地址", url);
		SetUrl(url);
	}

	@Override
	protected Object DeserializeResult(String responseBody) {
		SetChatAmountInvokeItemResult result = new SetChatAmountInvokeItemResult();
		JSONObject json = null;
		try {
			json = new JSONObject(responseBody);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		if (json == null) {
			return null;
		}
		result.status = json.optInt("status");
		result.msg = json.optString("msg");

		return result;
	}

}
